# -*- coding:utf-8 -*-
#! python3

# FaceCat-Python
#Shanghai JuanJuanMao Information Technology Co., Ltd 

from facecat_objc import *

gPaint = FCPaint() #创建绘图对象

#加载示例
def loadUI():
	xml = """<?xml version="1.0" encoding="utf-8"?>
	<html xmlns="facecat">
	<head>
	</head>
	<body>
		<div dock="fill" type="tab" selectedindex="0">
		<div name="TabPage" text="左右" type="tabpage">
			<div type="splitlayout" layoutstyle="LeftToRight" size="200,200" candragsplitter="true" splitterposition="100,5" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
			<div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
			<div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
			</div>
		</div>
		<div name="TabPage2" text="右左" type="tabpage">
			<div type="splitlayout" layoutstyle="RightToLeft" size="200,200" candragsplitter="true" splitterposition="100,5" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
			<div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
			<div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
			</div>
		</div>
		<div name="TabPage3" text="上下" type="tabpage">
			<div type="splitlayout" layoutstyle="TopToBottom" size="200,200" candragsplitter="true" splitterposition="100,5" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
			<div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
			<div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
			</div>
		</div>
		<div name="TabPage4" text="下上" type="tabpage">
			<div type="splitlayout" layoutstyle="BottomToTop" size="200,200" candragsplitter="true" splitterposition="100,5" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
			<div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
			<div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
			</div>
		</div>
		</div>
	</body>
	</html>
	"""
	renderFaceCat(gPaint, xml)

class AppDelegate(NSObject):
	def windowWillClose_(self, notification):
		os._exit(0)
	def applicationDidFinishLaunching_(self, notification):
		gPaint.size = FCSize(900, 770)
		window = NSWindow.alloc().initWithContentRect_styleMask_backing_defer_(
		NSMakeRect(0, 0, gPaint.size.cx, gPaint.size.cy),
		15,
		NSBackingStoreBuffered,
		False
		)
		window.setDelegate_(self)
		window.orderFrontRegardless()
		view = FCUIView.alloc().initWithFrame_(NSMakeRect(0, 0, gPaint.size.cx, gPaint.size.cy))
		view.paint = gPaint
		window.setContentView_(view)
		gPaint.view = view
		loadUI()

app = NSApplication.sharedApplication()
delegate = AppDelegate.alloc().init()
app.setDelegate_(delegate)
app.run()
